import request from "@/utils/request";

const LOG_BASE_URL = "/v3/manager/device";

class DeviceApi {
  /**
   * 根据id获取设备信息
   */
  static getdeviceID(id: string) {
    return request({
      url: `${LOG_BASE_URL}/id/${id}`,
      method: "get",
    });
  }

  /**
   * 批量修改设备规格
   *
   * @param queryParams 查询参数
   */
  static batchUpdateSpec(queryParams: batSpec) {
    return request({
      url: `${LOG_BASE_URL}/batchUpdateSpec`,
      method: "post",
      params: queryParams,
    });
  }
  /**
   * 根据铁塔编号获取设备信息(模糊查询)
   */
  static fuzzyByTower(deviceSN: string) {
    return request<any, deviceVODatalist>({
      url: `${LOG_BASE_URL}/fuzzyByTower`,
      method: "get",
      params: {
        tower: deviceSN,
      },
    });
  }
  /**
   * 根据设备编号获取设备信息(模糊查询)
   */
  static fuzzyByCode(deviceSN: string) {
    return request<any, deviceVODatalist>({
      url: `${LOG_BASE_URL}/fuzzyByCode`,
      method: "get",
      params: {
        code: deviceSN,
      },
    });
  }

  /**
   * 根据设备编号获取设备信息(精准查询)
   */
  static selectByCode(deviceSN: string) {
    return request<any, deviceVOData>({
      url: `${LOG_BASE_URL}/selectByCode`,
      method: "get",
      params: {
        code: deviceSN,
      },
    });
  }
  /**
   * 添加设备类型
   *
   */
  static gpsPage(data: GPSPageQuery) {
    return request<any, locationDevice>({
      url: `${LOG_BASE_URL}/gpsPage`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data,
    });
  }
  /**
   * 添加设备类型
   *
   * @param queryParams 查询参数
   */
  static addDevType(queryParams: DeviceTypeReq) {
    return request({
      url: `${LOG_BASE_URL}/save`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }

  /**
   * 获取设备类型分页列表
   *
   */
  static getFences(queryParams: FencesPageQuery) {
    return request<any, LogPageVO>({
      url: `${LOG_BASE_URL}/simplePage`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }

  /**
   * 编辑设备类型
   *
   */
  static editSave(queryParams: DeviceTypeReq) {
    return request({
      url: `${LOG_BASE_URL}/update`,
      method: "put",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }
  static BatchAllocate(queryParams: distributeDevice) {
    return request({
      url: `${LOG_BASE_URL}/BatchAllocate`,
      method: "post",
      params: queryParams,
    });
  }
  /**
   * 删除设备类型
   *
   */
  static deleteSave(queryParams: number) {
    return request({
      url: `${LOG_BASE_URL}/delete/${queryParams}`,
      method: "delete",
      headers: {
        "Content-Type": "application/x-www-form-urlencoded",
      },
    });
  }

  static upgradePage(queryParams: upgradePageVO) {
    return request<any, LogPageVO>({
      url: `${LOG_BASE_URL}/upgradePage`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }
}

export default DeviceApi;

export interface upgradePageVO {
  pages: any;
  deviceCode?: string;
}
/**
 * 日志分页查询对象
 */
export interface GPSPageQuery {
  pages?: any;
  customerId: string;
  deviceName?: string;
  deviceCode?: string;
  deviceTypeId?: string | number;
  deviceStatus?: string;
  onlineStatus?: string;
  expireStatus?: string;
  isChild?: boolean;
}

export interface batSpec {
  deviceSpecId: string;
  deviceIdList: Array<any>;
}
/**
 * 日志分页查询对象
 */
export interface LogPageQuery {
  /** 搜索关键字 */
  keywords?: string;
  pages?: any;
  module?: string;
  operation?: string;
  content?: string;
  type?: string;
  ip?: string;
  customerId?: number;
}

/**
 * 系统日志分页VO
 */
export interface LogPageVO {
  current: number;
  pages: number;
  records: Array<any>;
  size: number;
  total: number;
}

/**
 * 电子围栏分页
 */
export interface FencesPageQuery {
  /** 搜索关键字 */
  pages?: any;
  key?: string;
  status?: number;
  deviceType?: string;
}

/**
 * 添加电子围栏
 */
export interface addFencesPageQuery {
  /** 搜索关键字 */
  id?: string;
  fenceName: string;
  customerId: string;
  coordinateSet: Array<any>;
}

/**
 * 设备类型
 */
export interface DeviceTypeReq {
  id?: string;
  deviceName?: string;
  deviceTypeId?: string;
  deviceCode?: string;
  module?: string;
  softVer?: string;
  hardVer?: string;
  status?: number;
  deviceModelId?: string;
  deviceSpecId?: string;
  customerId?: string;
  towerNumber?: string;
  IMEI?: string;
  ICCID?: string;
  // imei?: string;
  // iccid?: string;
}
/**
 * 编辑设备类型
 */
export interface DeviceTypeEigt {
  id?: string;
  customerId: string;
}

/**
@date: 2024-09-11 15:32:05
分配设备
*/
export interface distributeDevice {
  customerId: string;
  deviceId: string[];
}

/**
分配设备
*/
export interface locationDevice {
  countInfo: countInfoDevice;
  data: LogPageVO;
}
export interface countInfoDevice {
  expired: number;
  notEnable: number;
  offline: number;
  online: number;
  scrap: number;
  total: number;
  notExpire: number;
}
export interface selectByData {
  deviceVOList: Array<deviceVOData>;
  total: number;
}
export interface deviceVOData {
  // expiredTime: string;
  createTime?: string;
  creatorId?: string;
  deviceModelId?: string;
  deviceName: string;
  positionTime?: string;
  deviceCode: string;
  deviceTypeId?: string | number;
  towerNumber: string;
  deviceTypeCode: string;
  onlineStatus: string;
  id?: string;
}

export interface deviceVODataTO {
  expiredTime: string;
  createTime?: string;
  creatorId?: string;
  deviceModelId?: string;
  deviceName?: string;
  positionTime?: string;
  deviceCode?: string;
  id?: string;
  customerId?: number;
  customerName?: string;
  deviceModelName?: string;
}
export interface deviceVODatalist {
  deviceVOList: Array<deviceVODataTO>;
  total: number;
}
